package club.justwill.single.persistence.dao;

import club.justwill.single.persistence.jpo.Model;
import club.justwill.single.persistence.support.BaseDao;
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Repository;

import javax.persistence.Query;
import java.util.List;

/**
 * Created by luoyu on 1/5/16.
 */
@Repository
@Scope(ConfigurableBeanFactory.SCOPE_SINGLETON)
public class ModelDao extends BaseDao<Model>{
    public List<Model> searchModels(int modelIndex, int modelSize) {

        Query query = em.createNamedQuery("Model.searchModels")
                .setFirstResult(modelIndex)
                .setMaxResults(modelSize);
        return query.getResultList();
    }
}
